/*
 * Copyright 2008 Nathan C Jones
 * 
 * This file is part of Fivehundred.
 * 
 * Fivehundred is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * Fivehundred is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * Fivehundred. If not, see <http://www.gnu.org/licenses/>. 
 */

package com.googlecode.fivehundred.model;

import java.util.Iterator;

/**
 * A deck describes the possible cards used in a game. TODO A deck should
 * probably be the card container that is used deal the cards from. Need to
 * either: a) figure out a better name for this, or b) merge this deck and the
 * deal-from deck so they are the same card container.
 * 
 * @author Nathan C Jones
 */
public interface Deck extends Iterable<Card> {

	/** The deck of cards used in 500. */
	public static final Deck FIVE_HUNDRED_DECK = new DefaultDeck(Card.JOKER, Card.ACE_OF_HEARTS, Card.ACE_OF_DIAMONDS, Card.ACE_OF_CLUBS,
			Card.ACE_OF_SPADES, Card.KING_OF_HEARTS, Card.KING_OF_DIAMONDS, Card.KING_OF_CLUBS, Card.KING_OF_SPADES, Card.QUEEN_OF_HEARTS,
			Card.QUEEN_OF_DIAMONDS, Card.QUEEN_OF_CLUBS, Card.QUEEN_OF_SPADES, Card.JACK_OF_HEARTS, Card.JACK_OF_DIAMONDS, Card.JACK_OF_CLUBS,
			Card.JACK_OF_SPADES, Card.TEN_OF_HEARTS, Card.TEN_OF_DIAMONDS, Card.TEN_OF_CLUBS, Card.TEN_OF_SPADES, Card.NINE_OF_HEARTS,
			Card.NINE_OF_DIAMONDS, Card.NINE_OF_CLUBS, Card.NINE_OF_SPADES, Card.EIGHT_OF_HEARTS, Card.EIGHT_OF_DIAMONDS, Card.EIGHT_OF_CLUBS,
			Card.EIGHT_OF_SPADES, Card.SEVEN_OF_HEARTS, Card.SEVEN_OF_DIAMONDS, Card.SEVEN_OF_CLUBS, Card.SEVEN_OF_SPADES, Card.SIX_OF_HEARTS,
			Card.SIX_OF_DIAMONDS, Card.SIX_OF_CLUBS, Card.SIX_OF_SPADES, Card.FIVE_OF_HEARTS, Card.FIVE_OF_DIAMONDS, Card.FIVE_OF_CLUBS,
			Card.FIVE_OF_SPADES, Card.FOUR_OF_HEARTS, Card.FOUR_OF_DIAMONDS);

	/**
	 * Get an iterator of all the cards in the deck. The order of the cards
	 * within the iterator is not guaranteed to match the card rank order within
	 * the deck.
	 * 
	 * @return an iterator of all the cards in the deck.
	 */
	Iterator<Card> iterator();

	/**
	 * Get the rank of a card within the deck. The best card (the joker) will
	 * have a rank of one (1), and lower cards will have a higher rank value. The
	 * cards are ranked according to their naturall "no trumps" ordering.
	 * 
	 * @param card the card to get the rank of.
	 * @return the card's deck ranking or <code>null</code> if the card is not
	 *         in the deck.
	 */
	Integer getRank(Card card);

	/**
	 * Get the size of the deck. The size cannot be negative. An empty deck has
	 * size zero.
	 * 
	 * @return the number of cards in the deck.
	 */
	Integer getSize();

	/**
	 * Get the renderer for generating the image of all cards in the deck. The
	 * back of all cards in the deck will be rendered with the same image.
	 * 
	 * @return the deck's card renderer for rendering the back of the cards.
	 */
	CardRenderer getCardBackRenderer();

}
